/* CTOS Web GUI 样式文件 */

/* 基础样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
}

/* 头部样式 */
header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 2rem;
  font-weight: 300;
}

nav {
  text-align: center;
}

nav a {
  color: white;
  text-decoration: none;
  margin: 0 1rem;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  transition: background-color 0.3s;
}

nav a:hover {
  background-color: rgba(255,255,255,0.2);
}

/* 主内容区域 */
main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* 账户管理页面样式 */
.accounts-container {
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  overflow: hidden;
}

.accounts-header {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
  padding: 2rem;
}

.accounts-header h2 {
  margin-bottom: 1.5rem;
  font-size: 1.8rem;
  font-weight: 300;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.account-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.account-selector label {
  font-weight: 500;
}

.account-selector select {
  padding: 0.5rem;
  border: none;
  border-radius: 5px;
  background: white;
  color: #333;
  font-size: 1rem;
  min-width: 150px;
}

.refresh-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: #007bff;
  color: white;
}

.btn-primary:hover {
  background: #0056b3;
  transform: translateY(-2px);
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.refresh-icon {
  animation: spin 2s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.auto-refresh {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.auto-refresh label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.auto-refresh input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

/* 错误消息 */
.error-message {
  background: #f8d7da;
  color: #721c24;
  padding: 1rem;
  margin: 1rem;
  border-radius: 5px;
  border: 1px solid #f5c6cb;
}

.error-message h3 {
  margin-bottom: 0.5rem;
}

/* 表格样式 */
.accounts-table-container {
  overflow-x: auto;
  margin: 0;
}

.accounts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.accounts-table th {
  background: #f8f9fa;
  padding: 1rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: #495057;
  border-bottom: 2px solid #dee2e6;
}

.accounts-table td {
  padding: 1rem 0.75rem;
  border-bottom: 1px solid #dee2e6;
  vertical-align: middle;
}

.account-row:hover {
  background-color: #f8f9fa;
}

/* 交易所徽章 */
.exchange-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.exchange-okx {
  background: #1e3a8a;
  color: white;
}

.exchange-backpack {
  background: #059669;
  color: white;
}

/* 余额样式 */
.balance-value {
  font-weight: 600;
  font-size: 1.1rem;
}

.balance-value.updating {
  color: #007bff;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 状态徽章 */
.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-正常 {
  background: #d4edda;
  color: #155724;
}

.status-错误 {
  background: #f8d7da;
  color: #721c24;
}

.status-未知 {
  background: #fff3cd;
  color: #856404;
}

/* 配置状态徽章 */
.config-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.config-ok {
  background: #d4edda;
  color: #155724;
}

.config-error {
  background: #f8d7da;
  color: #721c24;
}

/* 操作按钮组 */
.action-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.action-buttons .btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: #007bff;
  color: white;
}

.btn-primary:hover {
  background: #0056b3;
  color: white;
}

/* 摘要区域 */
.accounts-summary {
  background: #f8f9fa;
  padding: 1.5rem;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 1rem;
}

.summary-item {
  text-align: center;
}

.summary-label {
  display: block;
  font-size: 0.9rem;
  color: #6c757d;
  margin-bottom: 0.5rem;
}

.summary-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  color: #495057;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .refresh-controls {
    justify-content: center;
  }
  
  .accounts-table {
    font-size: 0.85rem;
  }
  
  .accounts-table th,
  .accounts-table td {
    padding: 0.75rem 0.5rem;
  }
  
  .accounts-summary {
    flex-direction: column;
    text-align: center;
  }
}

/* 加载动画 */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #007bff;
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* 隐藏/显示行 */
.account-row.hidden {
  display: none;
}

/* 账户详情页面样式 */
.account-detail-container {
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  overflow: hidden;
  margin: 2rem auto;
  max-width: 1400px;
}

.account-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2rem;
}

.breadcrumb {
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.breadcrumb a {
  color: white;
  text-decoration: none;
  opacity: 0.8;
}

.breadcrumb a:hover {
  opacity: 1;
}

.breadcrumb .separator {
  margin: 0 0.5rem;
  opacity: 0.6;
}

.breadcrumb .current {
  font-weight: 500;
}

.account-info h2 {
  margin-bottom: 1rem;
  font-size: 1.8rem;
  font-weight: 300;
}

.account-stats {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.8;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 600;
}

/* 标签页样式 */
.detail-tabs {
  padding: 0;
}

.tab-nav {
  display: flex;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

.tab-btn {
  padding: 1rem 2rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  color: #6c757d;
  transition: all 0.3s;
  border-bottom: 3px solid transparent;
}

.tab-btn:hover {
  background: #e9ecef;
  color: #495057;
}

.tab-btn.active {
  color: #007bff;
  border-bottom-color: #007bff;
  background: white;
}

.tab-content {
  padding: 0;
}

.tab-panel {
  display: none;
  padding: 2rem;
}

.tab-panel.active {
  display: block;
}

/* 面板头部 */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #dee2e6;
}

.panel-header h3 {
  margin: 0;
  color: #495057;
  font-size: 1.3rem;
  font-weight: 500;
}

.panel-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* 数据表格样式 */
.table-container {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #dee2e6;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: white;
}

.data-table th {
  background: #f8f9fa;
  padding: 1rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: #495057;
  border-bottom: 2px solid #dee2e6;
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid #dee2e6;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background-color: #f8f9fa;
}

.loading-cell, .no-data {
  text-align: center;
  color: #6c757d;
  font-style: italic;
  padding: 2rem !important;
}

/* 仓位和订单特定样式 */
.side-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.side-buy, .side-long {
  background: #d4edda;
  color: #155724;
}

.side-sell, .side-short {
  background: #f8d7da;
  color: #721c24;
}

.profit {
  color: #28a745;
  font-weight: 600;
}

.loss {
  color: #dc3545;
  font-weight: 600;
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-open, .status-active, .status-live {
  background: #d1ecf1;
  color: #0c5460;
}

.status-filled, .status-completed {
  background: #d4edda;
  color: #155724;
}

.status-cancelled, .status-canceled {
  background: #f8d7da;
  color: #721c24;
}

.status-pending {
  background: #fff3cd;
  color: #856404;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .account-header {
    padding: 1rem;
  }
  
  .account-stats {
    flex-direction: column;
    gap: 1rem;
  }
  
  .tab-nav {
    flex-direction: column;
  }
  
  .tab-btn {
    padding: 0.75rem 1rem;
    text-align: left;
  }
  
  .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  
  .panel-controls {
    justify-content: center;
  }
  
  .data-table {
    font-size: 0.8rem;
  }
  
  .data-table th,
  .data-table td {
    padding: 0.5rem 0.25rem;
  }
}

/* 指标页面样式 */
.topdogindex-container,
.allcoin-trend-container,
.kline-container {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* 单页模式下的容器特殊处理 */
.topdogindex-container.single-mode {
  max-width: none;
  margin: 0;
  padding: 0;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  position: relative;
}

.indicator-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2rem;
  border-radius: 10px 10px 0 0;
  margin-bottom: 0;
}

.breadcrumb {
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.breadcrumb a {
  color: white;
  text-decoration: none;
  opacity: 0.8;
}

.breadcrumb a:hover {
  opacity: 1;
}

.breadcrumb .separator {
  margin: 0 0.5rem;
  opacity: 0.6;
}

.breadcrumb .current {
  font-weight: 500;
}

.indicator-info h2 {
  margin-bottom: 0.5rem;
  font-size: 1.8rem;
  font-weight: 300;
}

.indicator-info p {
  opacity: 0.9;
  font-size: 1rem;
}

/* 控制面板 */
.controls-panel {
  background: white;
  padding: 1.5rem;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  margin-bottom: 2rem;
  display: flex;
  gap: 2rem;
  align-items: center;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-group label {
  font-weight: 500;
  color: #495057;
}

.control-group select {
  padding: 0.5rem;
  border: 1px solid #dee2e6;
  border-radius: 5px;
  background: white;
  color: #333;
  font-size: 1rem;
  min-width: 100px;
}

.control-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

/* 图表容器 */
.charts-container {
  margin-bottom: 2rem;
}

/* 网格布局模式 */
.charts-container.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(600px, 1fr));
  gap: 2rem;
}

/* 单页展示模式 */
.charts-container.charts-single {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 0.5rem;
  height: 80vh;
  width: 100vw;
  max-width: none;
  margin: 0;
  padding: 0 1rem;
  box-sizing: border-box;
}

/* 图表卡片基础样式 */
.chart-card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
}

.chart-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

/* 网格模式下的图表卡片 */
.chart-card-grid {
  min-height: 400px;
}

/* 单页模式下的图表卡片 */
.chart-card-single {
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
  margin: 0;
}

.chart-card-single .chart-header {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.chart-card-single .chart-header h3 {
  font-size: 1rem;
}

.chart-card-single .chart-content {
  flex: 1;
  min-height: 0;
  padding: 0.25rem;
}

.chart-card-single .chart-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.chart-card-single .chart-footer {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
}

.chart-header {
  background: #f8f9fa;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chart-header h3 {
  margin: 0;
  color: #495057;
  font-size: 1.1rem;
  font-weight: 500;
}

.chart-index {
  background: #007bff;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.chart-content {
  padding: 1rem;
  text-align: center;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-image {
  max-width: 100%;
  height: auto;
  border-radius: 5px;
  opacity: 0;
  transition: opacity 0.3s;
}

.chart-footer {
  background: #f8f9fa;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: #6c757d;
}

.chart-timeframe {
  font-weight: 500;
}

/* 单图表容器 */
.chart-container {
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  overflow: hidden;
  margin-bottom: 2rem;
}

/* 错误消息 */
.error-message {
  text-align: center;
  padding: 2rem;
  color: #dc3545;
}

.error-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.error-message p {
  margin: 0.5rem 0;
  font-weight: 500;
}

.error-message small {
  color: #6c757d;
}

/* 加载覆盖层 */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-overlay p {
  color: #495057;
  font-size: 1.1rem;
  margin: 0;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  /* 中等屏幕：单页模式改为2x3布局 */
  .charts-container.charts-single {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0.25rem;
    width: 100vw;
  }
}

@media (max-width: 768px) {
  .controls-panel {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  
  .control-group {
    justify-content: space-between;
  }
  
  /* 移动端：网格模式改为单列 */
  .charts-container.charts-grid {
    grid-template-columns: 1fr;
  }
  
  /* 移动端：单页模式改为单列 */
  .charts-container.charts-single {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(6, 1fr);
    height: auto;
    min-height: 120vh;
    gap: 0.25rem;
    width: 100vw;
  }
  
  .chart-content {
    min-height: 300px;
  }
  
  .chart-footer {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
  
  /* 移动端单页模式下的图表卡片 */
  .chart-card-single {
    min-height: 200px;
  }
  
  .chart-card-single .chart-header {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
  }
  
  .chart-card-single .chart-footer {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
  }
}
